<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>{:get_kv_val('website_name')}</title>
    <link rel="shortcut icon" href="{:get_kv_val('login_logo')}" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/login.css"/>
    <script src="__PUBLIC__/assets/js/jquery1x.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.form.min.js"></script>
    <script src="__PUBLIC__/js/admin/adminLogin.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/md5.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/base64.js" type="text/javascript" charset="utf-8"></script>

</head>
<body>

    <img id="bg" src="__PUBLIC__/img/login_bg.jpg" style="width: 100%;height: 100%;"/>
<!--    <img id="admin_login" src="{:get_kv_val('login_logo')}"/>-->
    <div class="middle-ovl">
        <img src="__PUBLIC__/img/login_middle-ovl.png">
    </div>
    <div class="logn-content">
        <div id="tip_div"></div>
        <div class="login-content-top">
            用户登录
        </div>
            <div class="login-content-input-content">
                <form id="login-form" method="post">
                    <table cellspacing="0">
                        <tr >
                            <td>
                                <div class="icon icon-user"></div>
                            </td>
                            <td colspan="2">
                                <input class="input-text" id="username" placeholder="请输入账号"/>
                                <input type="hidden" name="username" id="username_hidden"/>
                            </td>

                        </tr>
                        <tr class="marg-26">
                            <td>
                                <div class="icon icon-lock"></div>
                            </td>
                            <td colspan="2">
                                <input class="input-text" id="password" type="password" placeholder="请输密码"/>
                                <input type="hidden" name="password" id="password_hidden"/>
                            </td>
                        </tr>
<!--                        <tr class="marg-26">-->
<!--                            <td>-->
<!--                                <div class="icon icon-text"></div>-->
<!--                            </td>-->
<!--                            <td>-->
<!--                                <input class="input-verify" name="verify_code" id="verify_code" placeholder="请输入验证码"/>-->
<!--                            </td>-->
<!--                            <td>-->
<!--                                <img class="verify_img" src="__ROOT__/Admin/Login/verify_login"/>-->
<!--                            </td>-->
<!--                        </tr>-->
                    </table>
                </form>
                <div class="button-content">
                    <button class="login-button login-button-login" onclick="validate()">登录</button>
                    <button class="login-button reset-button" onclick="clear()">重置</button>
                </div>
            </div>

    </div>
</body>
</html>
<script>
    $(function() {
        $('#bg').css('height', window.innerHeight);
        $('#bg').css('width', window.innerWidth);
        $('.middle-ovl').css('width', window.innerWidth);
        $(".verify_img").click(function(){
            var time=Math.round(Math.random()*999)+3000;
            $(this).attr("src","/Admin/Login/verify_login?time="+time);
        });
        document.onkeydown = function(e){
            var ev = document.all ? window.event : e;
            if(ev.keyCode==13) {
                validate();
            }
        }
    });

    function validate(){
        var tip = $('#tip_div');
        var username = $('#username').val();
        var password = $('#password').val();
        var verify_code = $('#verify_code').val();
        if(username == ''){
            tip.text('请输入账号');
            return false;
        }else if(password == ''){
            tip.text('请输入密码');
            return false;
        }else if(verify_code == ''){
            tip.text('请输入验证码');
            return false;
        }
        var b = new Base64();
        $('#username_hidden').val(b.encode($('#username').val()));
        $('#password_hidden').val(hex_md5($('#password').val()));
        $('form').ajaxSubmit({
            url: '__ROOT__/Admin/Login/userLoginIn',
            dataType:'json',
            async: false,
            success: function(data) {
                if(data.status == 0){
                    tip.text('账号密码错误');
                    var time=Math.round(Math.random()*999)+3000;
                    $('.verify_img').attr("src","/Admin/Login/verify_login?time="+time);
                }else if(data.status == -1){
                    var time=Math.round(Math.random()*999)+3000;
                    $('.verify_img').attr("src","/Admin/Login/verify_login?time="+time);
                    tip.text('验证码错误，重新输入');
                }else if(data.status == 999){
                    tip.text('登录成功，请等待.....');
                    window.location.href = '/Admin/Index/index';
                }
            }
        });
    }

    function clear(){
        $('#login-form').form('clear');
    }


</script>
